package com.sxfq.loansupermarket.backsystem.modular.theTest.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.modular.base.SqlMapper;
import com.sxfq.loansupermarket.backsystem.modular.theTest.dao.IncompleteTestDao;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.IncompleteTestInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.SearchTestingInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.entity.TheTestInfo;
import com.sxfq.loansupermarket.backsystem.modular.theTest.service.IIncompleteTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class IncompleteTestServiceImpl implements IIncompleteTestService {

    @Autowired
    private IncompleteTestDao incompleteTestDao;
    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<IncompleteTestInfo> selectPageListByQueryGetMap(Page<IncompleteTestInfo> page, SearchTestingInfo searchInfo) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        params.put("userId", ShiroKit.getUser().getId());
        return incompleteTestDao.getQueryPage(page, params);
    }

    public TheTestInfo selectOneById(String id) {
        String sql = "SELECT * from the_test_info where id=#{id}";
        TheTestInfo theTestInfo = sqlMapper.selectOne(sql, id, TheTestInfo.class);
        return theTestInfo;
    }
}
